﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EducationGuide.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace EducationGuide.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {
        public DataTemplate subject { get; set; }
        public DataTemplate news { get; set; }
        public DataTemplate worksheet { get; set; }
         public DataTemplate category { get; set; }

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null)
            {
                if (item.GetType() == typeof(SampleDataItem))
                {
                    if ((item as SampleDataItem).UniqueId.StartsWith("subject"))
                        return subject;
                    if ((item as SampleDataItem).UniqueId.StartsWith( "news"))
                        return news;
                    if ((item as SampleDataItem).UniqueId.StartsWith("worksheet"))
                        return worksheet;
                }
                else if (item.GetType() == typeof(SampleDataItem1))
                {
                    if ((item as SampleDataItem1).UniqueId.StartsWith("category"))
                        return category;
                }

            }
            return base.SelectTemplateCore(item, container);
        }

    }
}
